```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring Boot条件注解完全指南</title>
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6B73FF 0%, #000DFF 50%, #0085FF 100%);
        }
        .code-block {
            background: #2d2d2d;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .hover-scale {
            transition: transform 0.3s ease;
        }
        .hover-scale:hover {
            transform: translateY(-5px);
        }
        .card-border {
            border: 1px solid rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
        }
        .card-border:hover {
            border-color: #3B82F6;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .mermaid {
            background: white;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
        }
        .section-divider {
            border-top: 2px dashed #E5E7EB;
            margin: 60px 0;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0.1em 0;
            color: #3B82F6;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 leading-tight">Spring Boot条件注解</h1>
                    <h2 class="text-xl md:text-2xl mb-6">灵活控制Bean加载的终极指南</h2>
                    <p class="text-lg opacity-90 mb-8">掌握条件注解，打造更智能、更灵活的Spring应用</p>
                    <div class="flex space-x-4">
                        <a href="#basic" class="bg-white text-blue-600 hover:bg-blue-50 px-6 py-3 rounded-full font-medium transition duration-300">开始学习</a>
                        <a href="#examples" class="border border-white text-white hover:bg-white hover:text-blue-600 px-6 py-3 rounded-full font-medium transition duration-300">查看示例</a>
                    </div>
                </div>
                <div class="md:w-1/2">
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714010834825-be494fbf-8383-4391-b402-b522118c96ff.png" alt="Spring Boot条件注解" class="rounded-lg shadow-xl hover-scale">
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <div class="text-center mb-12">
                <span class="text-blue-600 font-bold">INTRODUCTION</span>
                <h2 class="text-3xl font-bold mt-2">条件注解的核心价值</h2>
                <div class="w-20 h-1 bg-blue-600 mx-auto mt-4"></div>
            </div>
            
            <div class="drop-cap bg-gray-50 p-8 rounded-xl shadow-sm">
                <p class="text-lg text-gray-700">当谈及SpringBoot的条件注解时，我们实际上在谈论一种强大的机制，它能够根据特定条件来动态地加载或配置Bean，从而使得我们的应用程序更加灵活和智能。</p>
                
                <p class="mt-6 text-lg text-gray-700">条件注解是SpringBoot中的一个重要特性，它使得我们能够根据环境、配置或其他因素，在应用启动时根据条件自动加载所需的组件或配置，这为我们提供了一种高度可定制化和灵活性的方式来管理应用的行为和配置。通过条件注解，我们可以实现诸如基于不同环境的配置加载、根据特定条件决定是否启用某些功能或组件、根据系统属性或外部配置文件来决定Bean的创建等功能。这种能力使得我们可以轻松地根据不同的需求来定制我们的应用，而无需手动管理大量的配置文件或代码。</p>
            </div>
        </div>
    </section>

    <!-- Basic Concepts Section -->
    <section id="basic" class="py-16 px-4 md:px-0 bg-gray-50">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">BASIC CONCEPTS</span>
                <h2 class="text-3xl font-bold mt-2">基本概念</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 items-center mb-12">
                <div>
                    <p class="text-lg text-gray-700 mb-6">Spring Boot的条件注解是一种用于在应用程序启动时根据特定条件自动配置Bean或组件的机制。即在特定条件下决定是否加载某个 Bean 或配置，它允许我们根据应用程序的环境、配置、或其他因素，在运行时动态地决定某些组件是否应该被创建或加载，从而实现了一种灵活的自动配置方式。</p>
                    
                    <div class="bg-blue-50 border-l-4 border-blue-600 p-4 mb-6">
                        <h3 class="font-bold text-blue-800 mb-2"><i class="fas fa-check-circle mr-2"></i>主要作用</h3>
                        <p class="text-gray-700">Spring Boot的条件注解允许开发人员根据特定的条件来控制Bean的创建或者配置类的加载。当条件满足时，相应的Bean或者配置类会被加载，否则会被忽略。</p>
                    </div>
                </div>
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714011015020-22beb0ab-58d3-429f-9ec2-339538313398.png" alt="条件注解概念图" class="rounded-lg shadow-md hover-scale">
                </div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-tags"></i></div>
                    <h3 class="font-bold text-xl mb-3">注解类型</h3>
                    <p class="text-gray-600">Spring Boot提供了一系列条件注解，如<span class="font-mono bg-gray-100 px-2 py-1 rounded">@ConditionalOnClass</span>、<span class="font-mono bg-gray-100 px-2 py-1 rounded">@ConditionalOnMissingBean</span>、<span class="font-mono bg-gray-100 px-2 py-1 rounded">@ConditionalOnProperty</span>等。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-code"></i></div>
                    <h3 class="font-bold text-xl mb-3">使用方式</h3>
                    <p class="text-gray-600">可以标注在@Bean方法上，也可以标注在@Configuration类上，分别表示方法返回的Bean或整个配置类的生效依赖于条件判断。</p>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-cogs"></i></div>
                    <h3 class="font-bold text-xl mb-3">运行机制</h3>
                    <p class="text-gray-600">在Spring容器启动时，会根据条件注解的判断逻辑决定是否创建对应的Bean或加载配置类，实现动态控制。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Conditional Annotation Section -->
    <section class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">CORE ANNOTATION</span>
                <h2 class="text-3xl font-bold mt-2">@Conditional注解</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 items-center mb-12">
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714010973361-f5bdc031-3549-48a0-86e3-fe3e4b07e9c4.png" alt="@Conditional注解" class="rounded-lg shadow-md hover-scale">
                </div>
                <div>
                    <p class="text-lg text-gray-700 mb-6"><span class="font-mono bg-gray-100 px-2 py-1 rounded">@Conditional</span>注解是Spring Framework提供的一个条件注解，用于根据特定的条件来决定是否创建某个Bean或者配置类。通过使用<span class="font-mono bg-gray-100 px-2 py-1 rounded">@Conditional</span>注解，我们可以根据运行时环境、系统属性、配置项等条件来动态地控制Bean的创建。</p>
                    
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-check"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">作用原理</h4>
                                <p class="text-gray-600">根据条件来判断是否应该创建一个Bean或者配置类。当指定的条件满足时，对应的Bean将会被创建；否则，该Bean将不会被创建。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-project-diagram"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">条件接口</h4>
                                <p class="text-gray-600">需要实现<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">Condition</span>接口，并在<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">matches</span>方法中定义条件判断逻辑。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-code-branch"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">判断时机</h4>
                                <p class="text-gray-600">条件判断逻辑通常在<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">matches</span>方法中实现，通过<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">ConditionContext</span>获取运行时环境信息。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="bg-blue-50 rounded-xl p-6 mb-12">
                <h3 class="font-bold text-xl mb-4 text-blue-800"><i class="fas fa-lightbulb mr-2"></i>使用示例</h3>
                <p class="mb-4">下面是一个使用<span class="font-mono bg-blue-100 px-2 py-1 rounded">@Conditional</span>注解的完整示例，展示了如何根据环境条件动态创建Bean：</p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="code-block p-4 rounded-lg">
                        <pre class="text-gray-300"><code>// 定义条件类
public class OnDevelopmentCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, 
                          AnnotatedTypeMetadata metadata) {
        String env = context.getEnvironment()
                          .getProperty("spring.profiles.active");
        return "dev".equalsIgnoreCase(env);
    }
}

// 服务类
public class HelloService {
    private String message;
    
    public HelloService(String message) {
        this.message = message;
    }
    
    public void sayHello() {
        System.out.println(message);
    }
}</code></pre>
                    </div>
                    
                    <div class="code-block p-4 rounded-lg">
                        <pre class="text-gray-300"><code>// 配置类
@Configuration
public class AppConfig {

    @Bean
    @Conditional(OnDevelopmentCondition.class)
    public HelloService helloService() {
        return new HelloService(
            "Hello from development environment!"
        );
    }
}

// application.properties
spring.profiles.active=dev</code></pre>
                    </div>
                </div>
                
                <div class="mt-4 bg-white p-4 rounded-lg border border-blue-200">
                    <p class="text-gray-700"><span class="font-bold text-blue-600">执行结果：</span>当在开发环境下启动应用时，<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">HelloService</span> Bean会被创建；在其他环境下则不会创建该Bean。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Extended Annotations Section -->
    <section id="examples" class="py-16 px-4 md:px-0 bg-gray-50">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">EXTENDED ANNOTATIONS</span>
                <h2 class="text-3xl font-bold mt-2">@Conditional的扩展注解</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="mb-12">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714010867649-f48ba4b3-d074-4cf1-88df-44bd74374e9e.png" alt="扩展注解" class="rounded-lg shadow-md w-full hover-scale">
            </div>
            
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-cube"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnClass</h3>
                    <p class="text-gray-600 mb-4">当类路径中存在指定的类时，配置生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Configuration
@ConditionalOnClass(DataSource.class)
public class DataSourceConfig {
    // 配置代码
}</code></pre>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-ban"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnMissingClass</h3>
                    <p class="text-gray-600 mb-4">当类路径中不存在指定的类时，配置生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Configuration
@ConditionalOnMissingClass("com.example.MyClass")
public class MyConfig {
    // 配置代码
}</code></pre>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-box"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnBean</h3>
                    <p class="text-gray-600 mb-4">当容器中存在指定的Bean时，配置生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Bean
@ConditionalOnBean(name = "myBean")
public AnotherBean anotherBean() {
    return new AnotherBean();
}</code></pre>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-box-open"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnMissingBean</h3>
                    <p class="text-gray-600 mb-4">当容器中不存在指定的Bean时，配置生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Bean
@ConditionalOnMissingBean
public MyBean myBean() {
    return new MyBean();
}</code></pre>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-cog"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnProperty</h3>
                    <p class="text-gray-600 mb-4">当配置属性存在且值满足条件时生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Configuration
@ConditionalOnProperty(
    name = "feature.enabled",
    havingValue = "true"
)
public class FeatureConfig {
    // 配置代码
}</code></pre>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-sm card-border">
                    <div class="text-blue-600 text-2xl mb-4"><i class="fas fa-globe"></i></div>
                    <h3 class="font-bold text-xl mb-3">@ConditionalOnWebApplication</h3>
                    <p class="text-gray-600 mb-4">当应用是Web应用时，配置生效。</p>
                    <div class="code-block p-3 rounded-lg">
                        <pre class="text-xs text-gray-300"><code>@Configuration
@ConditionalOnWebApplication
public class WebConfig {
    // 配置代码
}</code></pre>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Principle Section -->
    <section class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">WORKING PRINCIPLE</span>
                <h2 class="text-3xl font-bold mt-2">条件注解的原理</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 items-center mb-12">
                <div>
                    <p class="text-lg text-gray-700 mb-6">Spring Boot的条件注解是基于条件判断的机制，用于根据特定条件来控制Bean的加载和配置的加载。提供了一种灵活的机制，使得应用程序的行为可以根据不同的条件进行动态调整。其原理主要涉及以下几个方面：</p>
                    
                    <div class="space-y-6">
                        <div>
                            <h3 class="font-bold text-xl mb-3 text-blue-700">1. 条件判断接口</h3>
                            <p class="text-gray-600">Spring Boot定义了<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">Condition</span>接口，所有的条件注解都是基于这个接口来实现的。这个接口中有一个<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">matches()</span>方法，用于判断条件是否满足。</p>
                        </div>
                        
                        <div>
                            <h3 class="font-bold text-xl mb-3 text-blue-700">2. 执行时机</h3>
                            <p class="text-gray-600">条件注解的判断逻辑在Spring容器启动时进行，在Bean加载的时候，会先判断这些Bean的条件注解是否满足条件，只有满足条件的Bean才会被加载到容器中。</p>
                        </div>
                        
                        <div>
                            <h3 class="font-bold text-xl mb-3 text-blue-700">3. 组合使用</h3>
                            <p class="text-gray-600">Spring Boot允许开发人员组合使用多个条件注解，这样可以更加灵活地控制Bean的加载条件。例如，可以同时使用<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">@ConditionalOnClass</span>和<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">@ConditionalOnBean</span>来确保某个Bean在指定类存在且指定Bean已经加载的情况下才被创建。</p>
                        </div>
                    </div>
                </div>
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714011198175-91590b90-1690-453b-bda0-ee7d304a5f37.png" alt="条件注解原理" class="rounded-lg shadow-md hover-scale">
                </div>
            </div>
            
            <div class="bg-blue-50 p-6 rounded-xl">
                <h3 class="font-bold text-xl mb-4 text-blue-800"><i class="fas fa-sitemap mr-2"></i>条件注解执行流程</h3>
                <div class="mermaid">
                    graph TD
                        A[启动Spring应用] --> B[加载配置类]
                        B --> C{是否有条件注解?}
                        C -->|是| D[执行条件判断]
                        C -->|否| E[创建Bean]
                        D --> F{条件满足?}
                        F -->|是| E
                        F -->|否| G[跳过Bean创建]
                </div>
            </div>
        </div>
    </section>

    <!-- Combined Usage Section -->
    <section class="py-16 px-4 md:px-0 bg-gray-50">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">ADVANCED USAGE</span>
                <h2 class="text-3xl font-bold mt-2">条件注解的组合使用</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 items-center mb-12">
                <div>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1714011122089-d4f2ddfe-b39d-44c9-bfa8-5a582dd68970.png" alt="组合使用条件注解" class="rounded-lg shadow-md hover-scale">
                </div>
                <div>
                    <p class="text-lg text-gray-700 mb-6">Spring Boot的条件注解允许开发人员根据多个条件来控制Bean的加载和配置的加载，可以通过组合不同的条件注解来实现更加灵活的条件判断。</p>
                    
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-layer-group"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">组合方式</h4>
                                <p class="text-gray-600">可以在一个Bean或者配置类上同时使用多个条件注解，所有条件都必须满足才能使得Bean或者配置类被加载。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-project-diagram"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">逻辑关系</h4>
                                <p class="text-gray-600">条件注解之间的逻辑关系通常是"与"的关系，所有条件都必须同时满足才能使得条件成立。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-cogs"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">应用场景</h4>
                                <p class="text-gray-600">可以根据不同的环境条件加载不同的配置、根据不同的条件选择不同的实现等。</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-sm">
                <h3 class="font-bold text-xl mb-4 text-blue-700"><i class="fas fa-code mr-2"></i>组合使用示例</h3>
                <p class="mb-4">下面是一个组合使用条件注解的示例，展示了如何根据类存在和属性配置共同决定Bean的加载：</p>
                
                <div class="code-block p-4 rounded-lg mb-4">
                    <pre class="text-gray-300"><code>@Configuration
@ConditionalOnClass({ DataSource.class })
@ConditionalOnProperty(
    prefix = "app.datasource", 
    name = "enabled", 
    havingValue = "true"
)
public class DataSourceConfig {

    @Bean
    @ConfigurationProperties(prefix = "app.datasource")
    public DataSource dataSource() {
        return DataSourceBuilder.create().build();
    }
}</code></pre>
                </div>
                
                <div class="bg-blue-50 p-4 rounded-lg border border-blue-200">
                    <p class="text-gray-700"><span class="font-bold text-blue-600">执行条件：</span>只有当类路径中存在<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">DataSource</span>类<strong>且</strong>配置属性<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">app.datasource.enabled</span>为<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">true</span>时，才会创建数据源Bean。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Configuration Relationship Section -->
    <section class="py-16 px-4 md:px-0 bg-white">
        <div class="container mx-auto max-w-5xl">
            <div class="mb-12">
                <span class="text-blue-600 font-bold">CONFIGURATION</span>
                <h2 class="text-3xl font-bold mt-2">条件注解与配置文件的关系</h2>
                <div class="w-20 h-1 bg-blue-600 mt-4"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div>
                    <p class="text-lg text-gray-700 mb-6">Spring Boot的条件注解与配置文件之间的关系非常紧密，它们共同构成了一个灵活而强大的配置管理机制，可以根据应用程序的配置情况来动态地加载或禁用组件，从而实现更好的配置管理和灵活性。</p>
                    
                    <div class="bg-blue-50 p-6 rounded-xl mb-6">
                        <h3 class="font-bold text-xl mb-3 text-blue-700"><i class="fas fa-file-alt mr-2"></i>与配置属性的交互</h3>
                        <p class="text-gray-600">通过<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">@ConditionalOnProperty</span>注解，可以根据配置属性的值来决定是否加载一个组件。这使得我们可以通过外部配置文件(如<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">application.properties</span>或<span class="font-mono bg-gray-100 px-1 py-0.5 rounded">application.yml</span>)来动态控制应用行为。</p>
                    </div>
                    
                    <div class="space-y-4">
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-toggle-on"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">功能开关</h4>
                                <p class="text-gray-600">通过配置文件中的属性来启用或禁用某个特性，从而控制相关组件是否加载。</p>
                            </div>
                        </div>
                        
                        <div class="flex items-start">
                            <div class="flex-shrink-0 h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-3">
                                <i class="fas fa-server"></i>
                            </div>
                            <div>
                                <h4 class="font-bold text-gray-800">环境适配</h4>
                                <p class="text-gray-600">根据不同环境(开发、测试、生产)配置不同的属性值，自动加载适合当前环境的组件。</p>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div>
                    <div class="code-block p-4 rounded-lg mb-6">
                        <pre class="text-gray-300"><code>// 使用@ConditionalOnProperty的组件
@Component
@ConditionalOnProperty(
    name = "feature.advanced.enabled",
    havingValue = "true",
    matchIfMissing = false
)
public class AdvancedFeatureService {
    // 高级功能实现
}

// application.properties
# 启用高级功能
feature.advanced.enabled=true</code></pre>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl border border-gray-200 shadow-sm">
                        <h3 class="font-bold text-xl mb-3 text-blue-700"><i class="fas fa-random mr-2"></i>配置与条件注解的关系图</h3>
                        <div class="mermaid">
                            graph LR
                                A[配置文件] -->|属性值| B[条件注解]
                                B --> C{条件判断}
                                C -->|满足| D[创建Bean]
                                C -->|不满足| E[跳过创建]
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Summary Section -->
    <section class="py-16 px-4 md:px-0 bg-gray-900 text-white">
        <div class="container mx-auto max-w-5xl text-center">
            <h2 class="text-3xl font-bold mb-6">掌握条件注解，构建更灵活的Spring应用</h2>
            <p class="text-xl text-gray-300 mb-8 max-w-3xl mx-auto">通过合理使用Spring Boot的条件注解，您可以创建出能够自动适应不同环境和配置的应用，大大减少手动配置的工作量，提高代码的可维护性和灵活性。</p>
            <div class="flex justify-center space-x-4">
                <a href="#" class="bg-blue-600 hover:bg-blue-700 px-6 py-3 rounded-full font-medium transition duration-300">返回顶部</a>
                <a href="http://www.yuque.com/jtostring" class="border border-gray-400 hover:bg-gray-800 px-6 py-3 rounded-full font-medium transition duration-300">更多教程</a>
            </div>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-800 text-white py-8 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold">技术小馆</h3>
                    <p class="text-gray-400">专业的IT技术学习平台</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">http://www.yuque.com/jtostring</a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```